﻿using System.Diagnostics;
using System.IO;
using Microsoft.Coding4Fun.TweetCraft.Wow;
using NUnit.Framework;

namespace Microsoft.Coding4Fun.TweetCraft.Tests
{
    [TestFixture]
    [Category("Integration")]
    public class WorldOfWarcraftIntegrationTest
    {
        private const string wowProcessName = "Wow.exe";

        private IWorldOfWarcraft worldOfWarcraft;

        [SetUp]
        public void SetUp()
        {
            // Create a new instance of the WorldOfWarcraft class implementing IWorldOfWarcraft
            worldOfWarcraft = new WorldOfWarcraft();

            // Assert that a World of Warcraft installation is detected
            Assert.IsTrue(worldOfWarcraft.IsDetected);
        }

        [Test]
        public void GetInstallPathTest()
        {
            // Get the install path of World of Warcraft
            string installPath = worldOfWarcraft.InstallPath;

            // Assert that the install path is not null and the directory exists
            Assert.IsNotNull(installPath);
            Assert.IsTrue(Directory.Exists(installPath));
        }

        [Test]
        public void IsRunningTest()
        {
            bool wowProcessFound = Process.GetProcessesByName(wowProcessName).Length > 0;

            // Assert that a running World of Warcraft is detected
            Assert.AreEqual(wowProcessFound, worldOfWarcraft.IsRunning);
        }
    }
}
